<div class="formVenue">
    <div class="venue">
        <?php for ($i = 0; $i < count($allVenues); $i++) { ?>
            <?php $model = $this->loadModel($allVenues[$i]->class_venue_id, 'ClassVenue'); ?>
            <?php $allBatchesWithVenue = $modelClassBatch->findAllByAttributes(array('class_venue_id' => $allVenues[$i]->class_venue_id, 'classes_id' => $allVenues[$i]->classes_id)); ?>
            <input type="hidden" name="venueIndex[]" id="venueIndex_venue_<?php echo $i; ?>_batch_0_earlydiscount_0" value="<?php echo $i; ?>" class="venueIndex"/> <?php /* This line use for function classVenueIndex means how many genarate venue venue remove the field venue then use this   */ ?>      
            <div class="addVenue_venue_<?php echo $i; ?>" id="venue_<?php echo $i; ?>">
                <div class="row">
                    <div class="rowLabel">Select Venue</div>
                    <div class="rowControl">
                        <?php echo CHtml::dropDownList('ClassVenue[venueId][]', $allVenues[$i]->class_venue_id, getVenueByBackendUser($model), array("empty" => "Select venue", 'class' => 'selectVenue selectbox', 'onchange' => 'getVanueDeatils(this.id);', 'id' => 'ClassVenue_venueId_' . $i)); ?>
                        <p id="Error_MSG_ClassVenue_venueId_<?php echo $i; ?>" class="customeClassvalidate" style="display:none">You have already selected this venue. So please select another venue!</p>
                    </div>
                </div>
                <div class="row">
                    <div class="rowLabel"><?php echo $form->labelEx($model, 'name'); ?>
                    </div>
                    <div class="rowControl"><?php echo $form->textField($model, 'name[]', array('maxlength' => 45, 'class' => 'input-xlarge requiredfield', 'id' => 'ClassVenue_name_' . $i, 'onblur' => 'getChnageinField(this.id)', 'value' => $model->name)); ?>
                    </div><!-- row -->
                </div>

                <div class="row">
                    <div class="rowLabel"><?php echo $form->labelEx($model, 'address_line1'); ?>
                    </div>
                    <div class="rowControl"><?php echo $form->textField($model, 'address_line1[]', array('maxlength' => 45, 'class' => 'input-xlarge requiredfield', 'id' => 'ClassVenue_address_line1_' . $i, 'value' => $model->address_line1)); ?>
                    </div><!-- row -->
                </div>

                <div class="row">
                    <div class="rowLabel"><?php echo $form->labelEx($model, 'address_line2'); ?>
                    </div>
                    <div class="rowControl"><?php echo $form->textField($model, 'address_line2[]', array('maxlength' => 45, 'class' => 'input-xlarge', 'id' => 'ClassVenue_address_line2_' . $i, 'value' => $model->address_line2)); ?>                  
                    </div><!-- row -->
                </div>

                <div class="row">
                    <div class="rowLabel"><?php echo $form->labelEx($model, 'venue_locality'); ?>
                    </div>
                    <div class="rowControl"><?php echo $form->textField($model, 'venue_locality[]', array('maxlength' => 145, 'class' => 'input-xlarge', 'id' => 'ClassVenue_venue_locality_' . $i, 'value' => $model->venue_locality, 'onkeyup' => "getLocality(this.id)")); ?>                  
                        <p class="note" style="width: 72%;margin: 0 auto;"> Note:<?php echo Message::LOCALITY_HELP; ?></p></div><!-- row -->
                </div>



                <div class="row">
                    <div class="rowLabel"><?php echo $form->labelEx($model, 'zip_code'); ?>
                    </div>
                    <div class="rowControl"><?php echo $form->textField($model, 'zip_code[]', array('maxlength' => 6, 'class' => 'input-xlarge requiredfield', 'id' => 'ClassVenue_zip_code_' . $i, 'value' => $model->zip_code)); ?>                  
                    </div><!-- row -->
                </div>


                <div class="row">
                    <div class="rowLabel"><?php echo $form->labelEx($model, 'country_id'); ?>
                    </div>
                    <div class="rowControl">
                        <?php echo CHtml::dropDownList('ClassVenue[country_id][]', $model->country_id, GxHtml::listData(Country::model()->findAllByAttributes(array('is_active' => SkillConfig::STATUS_ACTIVE)), 'id', 'name'), array('class' => 'selectbox requiredfield', 'id' => 'ClassVenue_country_id_' . $i, 'onchange' => 'getStateDependonCountry(this.id);')); ?>
                    </div><!-- row -->
                </div>
                <div class="row">
                    <div class="rowLabel"><?php echo $form->labelEx($model, 'state_id'); ?>
                    </div>
                    <div class="rowControl">
                        <?php echo CHtml::dropDownList('ClassVenue[state_id][]', $model->state_id, GxHtml::listData(State::model()->findAllByAttributes(array('is_active' => SkillConfig::STATUS_ACTIVE)), 'id', 'name'), array('class' => 'selectbox requiredfield', 'id' => 'ClassVenue_state_id_' . $i, 'onchange' => 'getCityDependonCountry(this.id);')); ?>
                        <?php echo $form->error($model, 'state_id'); ?>
                    </div><!-- row -->
                </div>
                <div class="row">
                    <div class="rowLabel"><?php echo $form->labelEx($model, 'city_id'); ?>
                    </div>
                    <div class="rowControl">
                        <?php echo CHtml::dropDownList('ClassVenue[city_id][]', $model->city_id, GxHtml::listData(City::model()->findAllByAttributes(array('status' => SkillConfig::STATUS_ACTIVE)), 'id', 'city_name'), array('class' => 'selectbox requiredfield', 'id' => 'ClassVenue_city_id_' . $i)); ?>
                    </div><!-- row -->
                </div>
                <div class="betch" >
                    <?php for ($j = 0; $j < count($allBatchesWithVenue); $j++) { ?>
                        <?php $allEarlyDiscountWithBatche = $modelClassEarlyDiscount->findAllByAttributes(array('class_batch_id' => $allBatchesWithVenue[$j]->id)); ?>
                        <?php $allGroupDiscountWithBatche = $modelGroupDiscount->findAllByAttributes(array('class_batch_id' => $allBatchesWithVenue[$j]->id)); ?>
                        <?php $allClassStructures = $modelClassStructures->findAllByAttributes(array('classes_id' => $allVenues[$i]->classes_id, 'class_batch_id' => $allBatchesWithVenue[$j]->id)); ?>
                        <div class="static_batch">
                            <div class="addremovebatch_adds_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_0">
                                <fieldset>
                                    <legend>Batch Detail <a href="javascript:void(0)" id="class_batcheshelp<?php echo $j; ?>" onmouseover="getTolltipId(this.id);" rel="popover" data-content="<?php echo Message::CLASSES_BATCHES; ?>" data-original-title="<?php echo Message::SKILL_HELP; ?>"><img src="<?php echo ThemePath(); ?>/img/icons/icon_tooltip.gif"/></a></legend>
                                    <div class="batchClone"> 
                                        <div class="image">
                                            <?php
                                            $this->renderPartial('/classBatch/_form_update', array('form' => $form,
                                                'model' => $modelClassBatch, 'allBatchesWithVenue' => $allBatchesWithVenue,
                                                'venueIndex' => $i,
                                                'batcheIndex' => $j,
                                            ));
                                            ?>
                                            <input type="hidden" class="venue_<?php echo $i; ?>_batch0" name="batchIndex[<?php echo $i; ?>][]" id="batchIndex_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_0"  value="<?php echo $j; ?>"/>
                                            <?php /* This line use for function batchIndex menas how many genarate batch in this venue  */ ?>  
                                        </div>
                                    </div>
                                    <fieldset>
                                        <legend>Batch Discount</legend>
                                        <?php for ($e = 0; $e < count($allEarlyDiscountWithBatche); $e++) { ?>
                                            <div id="venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_<?php echo $e; ?>" class="addEarlyvenue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_0">                               
                                                <div id="batchEarlydiscount_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_0_<?php echo $e; ?>"><div class="clear"></div><div class="classStructureControl">
                                                        <div class="rowControl"><input type="text" onkeypress="return isNumberKey(event)" placeholder="Discount Price" id="ClassEarlyDiscount_discount_price_0<?php echo $j; ?><?php echo $i; ?>" name="ClassEarlyDiscount[ClassVenue][<?php echo $i; ?>][ClassBatch][<?php echo $j; ?>][discount_price][]" class="input-medium <?php if ($allEarlyDiscountWithBatche[$e]->discount_price <> "") { ?>requiredfield<?php } ?>" onblur="enableDisableEarlyBirdTextField(this.id);" value="<?php echo $allEarlyDiscountWithBatche[$e]->discount_price; ?>" <?php if ($allEarlyDiscountWithBatche[$e]->discount_price == "") { ?> readonly="readonly" <?php } ?>></div>
                                                        <div class="rowControl"><input type="text" onkeypress="return isNumberKey(event)" placeholder="In Percentage" id="ClassEarlyDiscount_in_percentage_0<?php echo $j; ?><?php echo $i; ?>" name="ClassEarlyDiscount[ClassVenue][<?php echo $i; ?>][ClassBatch][<?php echo $j; ?>][in_percentage][]" class="input-medium <?php if ($allEarlyDiscountWithBatche[$e]->in_percentage <> "") { ?>requiredfield<?php } ?>" onblur="enableDisableEarlyBirdTextField(this.id);" value="<?php echo $allEarlyDiscountWithBatche[$e]->in_percentage; ?>" <?php if ($allEarlyDiscountWithBatche[$e]->in_percentage == "") { ?> readonly="readonly" <?php } ?>></div>
                                                        <div class="rowControl"> <input type="text" placeholder="Valid To"  onclick="hasDatepicker(this.id)" onkeyup="hasDatepicker(this.id)" id="ClassEarlyDiscount_valid_to_0<?php echo $j; ?><?php echo $i; ?>" name="ClassEarlyDiscount[ClassVenue][<?php echo $i; ?>][ClassBatch][<?php echo $j; ?>][valid_to][]" class="input-medium requiredfield" value="<?php echo $allEarlyDiscountWithBatche[$e]->valid_to; ?>" onpaste="return false;"></div>
                                                        <div class="rowControl"> <a onclick="removeEarlyDiscount(this.id);" id="batchEarlydiscount_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_0_<?php echo $e; ?>" class="link-remove"><span>Remove Early Discounts</span></a></div></div></div>
                                            </div>
                                        <?php } ?>

                                        <div id="venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_<?php echo $e; ?>" class="addEarlyvenue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_<?php echo $e; ?>"></div>

                                        <div style="clear: both;height: 10px;margin-top: 10px;"><a class="link-buttonadd" id="venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_<?php echo $e; ?>" onclick="updateEarlyDiscount(this.id);"><span>Add Early Discounts</span></a></div>
                                        <hr class="hrclass">
                                        <?php for ($g = 0; $g < count($allGroupDiscountWithBatche); $g++) { ?>      
                                            <div id="venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_groupdiscount_0" class="addGroupDiscount_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>">
                                                <div id="groupdiscount_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_<?php echo $e; ?>_<?php echo $g; ?>"><div class="clear"></div><div class="classStructureControl">
                                                        <div class="rowControl"><input type="text" onkeypress="return isNumberKey(event)" placeholder="Discount Amount" id="GroupDiscount_discount_amount_0<?php echo $j; ?><?php echo $i; ?>" name="GroupDiscount[ClassVenue][<?php echo $i; ?>][ClassBatch][<?php echo $j; ?>][discount_amount][]"  class="input-medium <?php if ($allGroupDiscountWithBatche[$g]->discount_amount <> "") { ?>requiredfield<?php } ?>"  onblur="enableDisableGroupDiscountTextField(this.id);"  value="<?php echo $allGroupDiscountWithBatche[$g]->discount_amount; ?>" <?php if ($allGroupDiscountWithBatche[$g]->discount_amount == "") { ?> readonly="readonly" <?php } ?>></div>
                                                        <div class="rowControl"><input type="text" onkeypress="return isNumberKey(event)" placeholder="Discount in percentage" id="GroupDiscountDiscount_in_percentage_0<?php echo $j; ?><?php echo $i; ?>" name="GroupDiscount[ClassVenue][<?php echo $i; ?>][ClassBatch][<?php echo $j; ?>][discount_in_percentage][]" class="input-medium <?php if ($allGroupDiscountWithBatche[$g]->discount_in_percentage <> "") { ?>requiredfield<?php } ?>" onblur="enableDisableGroupDiscountTextField(this.id);" value="<?php echo $allGroupDiscountWithBatche[$g]->discount_in_percentage; ?>" <?php if ($allGroupDiscountWithBatche[$g]->discount_in_percentage == "") { ?> readonly="readonly" <?php } ?>></div>
                                                        <div class="rowControl"><input type="text" onkeypress="return isNumberKey(event)" placeholder="Group Size" id="GroupDiscount_group_size_0<?php echo $j; ?><?php echo $i; ?>" name="GroupDiscount[ClassVenue][<?php echo $i; ?>][ClassBatch][<?php echo $j; ?>][group_size][]" class="input-medium requiredfield" value="<?php echo $allGroupDiscountWithBatche[$g]->group_size; ?>"></div>
                                                        <div class="rowControl"> <a onclick="removeGroupDiscount(this.id);" id="groupdiscount_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_<?php echo $e; ?>_<?php echo $g; ?>" class="link-remove"><span>Remove Group Discounts</span></a></div></div></div>
                                            </div>
                                        <?php } ?>                                                  


                                        <div id="venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_groupdiscount_<?php echo $g; ?>" class="addGroupDiscount_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_groupdiscount_0"></div>


                                        <div style="clear: both;height: 10px;margin:10px 0px 10px 0px;"><a class="link-buttonadd" id="venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_groupdiscount_0" onclick="updateGroupDiscount(this.id);"><span>Add Group Discounts</span></a></div>
                                        <hr class="hrclass">
                                        <div style="clear: both;height: 10px;margin:10px 0px 10px 0px;">Add Schedule:&nbsp;&nbsp;&nbsp;<?php echo CHtml::dropDownList('ClassBatch[ClassVenue][' . $i . '][schedule_id][]', $allBatchesWithVenue[$j]->schedule_id, getAllSchedule('class'), array('class' => 'selectbox requiredfield venue_' . $i . '_batch_' . $j . '_earlydiscount_0', 'id' => 'venue_' . $i . '_batch_' . $j . '_earlydiscount_0', 'onchange' => 'updateCustomeSchedule(this.id);')); ?></div>
                                        <div class="clear" style="height: 20px;"></div>

                                        <?php if ($allBatchesWithVenue[$j]->schedule_id == 4) { ?>
                                            <div style="clear:both;"></div><div class="addschedule_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_0">
                                                <?php
                                                $modelBatcheSession = new BatcheSession;
                                                $allSessionWithBatche = $modelBatcheSession->findAllByAttributes(array('batche_id' => $allBatchesWithVenue[$j]->id));
                                                for ($k = 0; $k < count($allSessionWithBatche); $k++) {
                                                    ?>
                                                    <div style="clear:both;"></div><div class="addSchedule_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_<?php echo $k; ?>">
                                                        <div class="classStructureControl">
                                                            <div class="rowControl"><input class="input-medium requiredfield" onclick="hasDatepicker(this.id)" onkeyup="hasDatepicker(this.id)"  name="ClassScheduleSession[ClassVenue][<?php echo $i; ?>][ClassBatch][<?php echo $j; ?>][date][]" id="schedule_start_date_<?php echo $k; ?>_venue_<?php echo $i; ?>b<?php echo $j; ?>" placeholder="Start Date" type="text" value="<?php echo $allSessionWithBatche[$k]->date; ?>" readonly="readonly" onpaste="return false;"></div>
                                                            <div class="rowControl  bootstrap-timepicker"><input onkeyup="hastimpiker(this.id)" onclick="hastimpiker(this.id)" class="input-medium hasTimepicker requiredfield" name="ClassScheduleSession[ClassVenue][<?php echo $i; ?>][ClassBatch][<?php echo $j; ?>][start_time][]" id="ClassBatch_start_time_<?php echo $k; ?>_venue_<?php echo $i; ?>b<?php echo $j; ?>" placeholder="Start Time" type="text" value="<?php echo $allSessionWithBatche[$k]->start_time; ?>" readonly="readonly" onpaste="return false;"><span class="add-on"><i class="icon-time"></i></span></div>
                                                            <div class="rowControl  bootstrap-timepicker"><input onkeyup="hastimpiker(this.id)" onchange="timeCheck(this.id);" onclick="hastimpiker(this.id)" class="input-medium hasTimepicker requiredfield" name="ClassScheduleSession[ClassVenue][<?php echo $i; ?>][ClassBatch][<?php echo $j; ?>][end_time][]" id="ClassBatch_end_time_<?php echo $k; ?>_venue_<?php echo $i; ?>b<?php echo $j; ?>" placeholder="End Time" type="text" value="<?php echo $allSessionWithBatche[$k]->end_time; ?>" readonly="readonly" onpaste="return false;"><span class="add-on"><i class="icon-time"></i></span></div>
                                                            <div class="rowControl"> <a class="link-remove" id="venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_<?php echo $k; ?>" onclick="removeCustomeSchedule(this.id);"><span>Remove Session</span></a></div>
                                                            <div class="errorMessage error_end_time_<?php echo $k; ?>_venue_<?php echo $i . 'b' . $j; ?> dateTimeErrormsg"></div></div> </div>

                                                <?php } ?></div>                                                  
                                            <div style="display:'';clear: both;" class="ShowDiv_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_0"><a href="javascript:void(0)" class="link-buttonadd" id="venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_0" onclick="updateCustomeSchedule(this.id);">Add Session</a></div>

                                        <?php } else { ?>  
                                            <div class="addschedule_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_0"></div>
                                            <div style="display:none;clear: both;" class="ShowDiv_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_0"><a href="javascript:void(0)" class="link-buttonadd" id="venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_earlydiscount_0" onclick="updateCustomeSchedule(this.id);">Add Session</a></div>
                                        <?php } ?>
                                    </fieldset>

                                    <!--Here starting class srtucture per batch-->

                                    <fieldset>	
                                        <legend>Class Structures:</legend>
                                        <div class="image">
                                            <div style="clear:both;"></div>
                                            <?php
                                            $this->renderPartial('/classStructures/_form', array('model' => $modelClassStructures, 'modelClassCourse' => $modelClasses,
                                                'type' => 'class', 'form' => $form,
                                                'venueIndex' => $i,
                                                'batcheIndex' => $j,
                                                'allCourseStructure' => $allClassStructures,
                                            ));
                                            ?> 
                                        </div>
                                    </fieldset>



                                    <?php if ($j > 0) { ?>								
                                        <div style="clear: both;height: 10px;margin:10px 0px 10px 0px;">
                                            <a onclick="removeupdateBatch(this.id);" id="addremovebatch_adds_venue_<?php echo $i; ?>_batch_<?php echo $j; ?>_0" class="link-remove"><span>Remove Batch</span></a>
                                        </div>
                                    <?php } ?>								




                                </fieldset>
                            </div>
                        </div>

                    <?php } ?>  
                    <input type="hidden" name="classVenueKey" id="classVenueKey_venue_<?php echo $i; ?>_batch_<?php echo $j - 1; ?>" value="<?php echo $i; ?>"><?php /* This line use for function clasvenuekey means how many genarate venue  */ ?>                  
                    <div class="addbatch_venue_<?php echo $i; ?>_batch"></div>
                    <div style="clear: both;height: 10px;margin-top: 10px;"></div>
                    <a class="link-buttonadd add_venue_<?php echo $i; ?>_batch_<?php echo $j - 1; ?>" id="adds_venue_<?php echo $i; ?>_batch_<?php echo $j - 1; ?>" onclick="updateBatch(this.id);"><span>Add Batch</span></a>

                </div>

                <?php if ($i > 0): ?>
                    <div style="clear: both;height: 10px;margin-top: 20px;"> <a onclick="removeVenue(this.id);" id="venue_<?php echo $i; ?>" class="link-remove"><span>Remove Venue</span></a></div><?php endif; ?>
                <hr class="hrclass">	
            </div>
        <?php } ?>   
        <div id="venue_<?php echo $i; ?>" class="addVenue_venue_<?php echo $i; ?>"></div>
    </div>

    <div style="clear: both;height: 10px;margin-top: 10px;"></div>
    <div id="venue_add"><a class="link-buttonadd add_venue_<?php echo $i - 1; ?>" id="add_venue_<?php echo $i - 1; ?>" onclick="updateVenue(this.id);"><span>Add venue</span></a></div>
    <input type="hidden" name="classVenuecountryId" id="classVenuecountryId"><?php /* This line use for function getAllCountry() select all country when genrate javascript form */ ?>  
    <input type="hidden" name="classVenuestateId" id="classVenuestateId"> <?php /* This line use for function getAllSatte() select all state when genrate javascript form */ ?>  
    <input type="hidden" name="classVenuecityId" id="classVenuecityId"><?php /* This line use for function getAllCity select all city when genrate javascript form */ ?>  
    <input type="hidden" name="selectVenuename" id="selectVenuename"> <?php /* This line use for function getVenueName  select all Venue name when genrate javascript form */ ?>   


    <hr class="hr" style="clear:both;background-color: #1d2e7b;height: 2px;">
    <div class="row" style="clear:both;">
        <div class="rowLabel">Other Information
        </div>
        <div class="rowControl"><?php echo $form->textArea($modelClasses, 'class_other_information'); ?>
            <?php echo $form->error($modelClasses, 'class_other_information'); ?>
        </div><!-- row -->
    </div>
    <hr class="hr" style="clear:both;background-color: #1d2e7b;height: 2px;">
    <div class="image">
        <?php $this->renderPartial('/ticketBooked/_form', array('form' => $form, 'model' => $modelTicketBooked, 'modelClasses' => $modelClasses, 'type' => 'class')); ?>
    </div>


</div>
<!-- form -->



